import { reqGetCategoryListData } from '@/api'
const state = {
  categoryList: [],
}
const actions = {
  async getCategoryListData({ commit }) {
    const result = await reqGetCategoryListData()
    if (result.code === 200) {
      commit('SAVE_CATEGORY_LIST_DATA', result.data)
    } else {
      console.log(result.message)
    }
  },
}
const mutations = {
  SAVE_CATEGORY_LIST_DATA(state, payload) {
    state.categoryList = payload ? payload : []
  },
}
const getters = {}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
}
